window.addEventListener('load', function() {
    //监听导航栏
    var one_all = document.querySelector('.one-all')
    var two_all = document.querySelector('.two-all')
        //菜单点开隐藏
    var tit = document.querySelectorAll(".four-list")
    var p = document.querySelectorAll(".five-list")
        // console.log(p[1]);

    for (var i = 0; i < p.length; i++) {
        (function(a) {
            p[a].addEventListener("mouseenter", () => {
                p[a].style.display = "block"
            })
            p[a].addEventListener("mouseout", () => {
                p[a].style.display = "none"
            })
        })(i)
    }
    for (var i = 0; i < tit.length; i++) {
        tit[i].dataset.num1 = i
        tit[i].onmousemove = function() {
            p[this.dataset.num1].classList.remove("hide")
            this.classList.add('add-four')
        }
        tit[i].onmouseout = function() {
            p[this.dataset.num1].classList.add("hide")
            this.classList.remove('add-four')
        }
    }

    var tit1 = document.querySelectorAll(".tab-item")
    var p1 = document.querySelectorAll(".eight-key")
    for (var i = 0; i < tit1.length; i++) {
        tit1[i].dataset.index = i
        tit1[i].onclick = function() {
            for (var j = 0; j < tit1.length; j++) {
                p1[j].style.display = 'none'
                tit1[j].classList.remove('item')
            }
            p1[this.dataset.index].style.display = 'block'
            this.classList.add('item')
        }
    }

    //定时器
    var hour = document.querySelector('.hour')
    var minute = document.querySelector('.minute')
    var second = document.querySelector('.second')
    var inputTime = +new Date('2021-12-30 18:00:00');
    setInterval(djs, 1000);

    function djs() {
        var nowTime = +new Date();
        var times = (inputTime - nowTime) / 1000;
        var h = parseInt(times / 60 / 60 % 24); //时
        h = h < 10 ? '0' + h : h
        hour.innerHTML = h;
        var m = parseInt(times / 60 / 60 % 60); //分
        m = m < 10 ? '0' + m : m
        minute.innerHTML = m;
        var s = parseInt(times % 60); //秒
        s = s < 10 ? '0' + s : s
        second.innerHTML = s;
    }
    //图片放大缩小图 
    var six_list = document.querySelectorAll(".six-list")
    for (var i = 0; i < six_list.length; i++) {
        six_list[i].onmouseenter = function() {
            for (var j = 0; j < six_list.length; j++) {
                console.log(six_list[j])
                six_list[j].classList.add("six2")
                six_list[j].children[0].classList.add("six1")
                six_list[j].children[0].children[0].children[0].classList.add("six3")
                six_list[j].children[1].children[0].classList.add("six4")
            }
            this.classList.remove("six2")
            this.children[0].classList.remove("six1")
            this.children[0].children[0].children[0].classList.remove("six3")
            this.children[1].children[0].classList.remove("six4")
        }
    }

    var a = document.querySelectorAll('.nav-item')[2]
    var b = document.querySelector('.right-nav')
    a.onclick = function() {
        this.style = "background:#e20000"
        document.documentElement.scrollTop = 0
    }
    window.onscroll = function() {
        if (document.documentElement.scrollTop >= 156) {
            two_all.classList.add('nave')
            document.querySelector('.two-list').classList.add('nave-two')
            document.querySelector('.cube-bottom').style = "display:none"
            document.querySelector('.shop').style = "display:none"
            document.querySelector('#ipt1').style = "width:613px"

        } else {
            two_all.classList.remove('nave')
            document.querySelector('.two-list').classList.remove('nave-two')
            document.querySelector('.cube-bottom').style = "display:flex"
            document.querySelector('.shop').style = "display:flex"
            document.querySelector('#ipt1').style = "width:435px"
        }
        if (document.documentElement.scrollTop >= 655) {
            b.style = "display:block"
            document.querySelector('.left-nav').style = "display:block"
        } else {
            b.style = "display:none"
            document.querySelector('.left-nav').style = "display:none"
        }
    }
    b.onclick = function() {
        document.documentElement.scrollTop = 0
    }
    var c = document.querySelectorAll('.nav-item-maodian')[0]
    c.onclick = function() {
        this.style = "background:#e20000;"
        document.documentElement.scrollTop = 652
        d.style = "background:rgba(0,0,0,.6);"
        e.style = "background:rgba(0,0,0,.6);"
        f.style = "background:rgba(0,0,0,.6);"
    }
    $('.nav-item-maodian').click(function() {
        $(".nav-item-maodian").removeClass('zz')
        $(this).addClass('zz')
    })

    var tit2 = document.querySelectorAll(".title-item")
    var p2 = document.querySelectorAll(".title-content")
    console.log(tit2, p2);
    for (var i = 0; i < tit2.length; i++) {
        tit2[i].dataset.txt = i
        tit2[i].onclick = function() {
            for (var j = 0; j < p2.length; j++) {
                console.log(p2[j]);
                p2[j].style.display = "none"
                tit2[j].classList.remove('item')
            }
            p2[this.dataset.txt].style.display = 'block'
            this.classList.add('item')
        }
    }
    var en = document.querySelectorAll('.eve-tit p')
    var ed = document.querySelector('.eve-conter').children
    console.log(en, ed)
    for (var i = 0; i < en.length; i++) {
        en[i].dataset.num = i
        en[i].onclick = function() {
            for (var j = 0; j < en.length; j++) {
                ed[j].style.display = "none"
                en[j].classList.remove('moon')
            }
            ed[this.dataset.num].style.display = "flex"
            this.classList.add('moon')
        }
    }
    var zc = document.querySelector('.zc')
    zc.onclick = () => {
        window.location.href = "login2.html"
    }
})